#pragma once
#include "BasicFunction.h"

class CWaveletTransform
{
public:
//Functions
	//Constructe a wavelet transform class
	CWaveletTransform(double** input, int inputcolumn, int inputrow);
	/* !!! Remember: for images, the inputcolumn is the width, while the inputrow is the height !!!*/
	//Set the wavelet transform parameters
	bool		SetParameters(int DecomposeLevel, int TypeOfWavelet);
	//Do the transform
	void		PerformTransform();
	//Get the vertical decomposition
	double**	GetVertical(int VerticalLevel, int* DataColumn, int* DataRow);
	//Get the horitontal decomposition
	double**	GetHorizontal(int HorizontalLevel, int* DataColumn, int* DataRow);
	//Get the approximation
	double**	GetApproximation(int ApproximationLevel, int* DataColumn, int* DataRow);
	//Get the diagonal decomposition
	double**	GetDiagonal(int DiagonalLevel,  int* DataColumn, int* DataRow);
	//Get the vertical decomposition
	double***	GetVertical(void);
	//Get the horizontal decomposition
	double***	GetHorizontal(void);
	//Get the diagonal decomposition
	double***	GetDiagonal(void);
	//Get the Approximation
	double***	GetApproximation(void);
	//Get new columns
	int*		GetColumns(void);
	//Get new rows
	int*		GetRows(void);

	//Perform the wavelet transform from an inpu
	bool		WaveletTransform(double** input, int inputcolumn, int inputrow,
									double** approximation, double** horizontal,
									double** vertical, double** diagonal,
									int* datacolumn, int* datarow);
	//Filter a matrix with the wavelet filter in columns and downsampling
	void		WaveletFilterColumn(double** input, int inputcolumn, int inputrow,
									double** destination, double* filter, int filtersize);
	//Filter a matrix with the wavlet filter in rows and downsampling
	void		WaveletFilterRow(double** input, int inputcolumn, int inputrow,
									double** destination, double* filter, int filtersize);
	//Empty the transform
	void		WaveletDestroy(void);
	~CWaveletTransform(void);

private:
//Data members
	double**	m_InputData;			//Inputdata
	double***	Approximation;			//Approximation at different levels
	double***	Diagonal;				//Diagonal at different levels
	double***	Horizontal;				//Horizontal at different levels
	double***	Vertical;				//Vertical at different levels
	int			m_DecompositionLevel;	//Levels to decompose
	int			m_TypeOfWavelet;		//Wavelet filter to decompose
	int			m_InputColumn;			//Input columns
	int			m_InputRow;				//Input rows
	int*		m_NewColumn;		//Columns at each level
	int*		m_NewRow;			//Rows at each level
	CBasicFunction bf;					//Basic operation
};
